"""
@Project ：zzzr_api_test 
@File    ：conftest.py
@IDE     ：PyCharm 
@Author  ：ZSR
@Date    ：2023/3/2 23:50 
"""

import os
import pytest
from time import sleep
from tool import get_cookie
from tool.read_file import ReadFile
from tool.log import logger
from config.config import dd_path


@pytest.fixture(scope='session', autouse=True)
def session_controller():
    """全局前置和后置"""
    """测试开始，写入cookie"""
    cookie = get_cookie()
    ReadFile.yaml_write_cookie(cookie)
    logger.info(f"更新后的cookie为：{cookie}")
    yield

    sleep(15)
    os.system(f'python {dd_path}')
    logger.info('---------------------- 测试结束 ----------------------')
